package com.zzz.test;

import java.util.LinkedList;

/**
 * @author zhuzhizun
 * @date 2021/8/31
 */
public class MinStack {

    private LinkedList<Integer> linkedList;

    public MinStack() {
        linkedList = new LinkedList();
    }

    public void push(int x) {
        linkedList.add(x);
    }

    public void pop() {
        linkedList.removeLast();
    }

    public int top() {
        return linkedList.getLast();
    }

    public int min() {
        return linkedList.stream().mapToInt(Integer::intValue).min().getAsInt();
    }


}
